/**
 * 用于根据id查询
 * @param p_params 传入的参数，具体说明见下面备注
 * @author sunflower
 * @returns
 */
var QueryById=function(p_params){
	if(!p_params) return;
	
	this._url=p_params.url;			// http://127.0.0.1:8090/iserver/services/data-China400/rest/data/featureResults.json
	this._dtSource=p_params.dataSource;
	this._dtSet=p_params.dataSet;
	this._callback=p_params.callback;
	
};

/**
 * 查询
 * @param p_ids 1,2,3
 */
QueryById.prototype.search=function(p_ids){
	
	// 定义为get后的处理使用
	var _obj=this;
	
	var _params=this.initPostParams(p_ids);
	
	this._url+="?returnContent=true";
	
	$.post(this._url,_params,function(p_data){
		
		if(p_data){
			/// 处理数据
			for(var i in p_data.features){
				
				for(var p_item in p_data.features[i].fieldNames){
					var _name=p_data.features[i].fieldNames[p_item];
					if(typeof(_name)==="string")
					p_data.features[i][_name.toUpperCase()]=p_data.features[i].fieldValues[p_item];
				}
			}
			
			if(_obj._callback) _obj._callback(p_data);
		}else{
			console.info("没有数据");
		}
	});
};

/***
 * 构造请求参数
 * @param p_ids 1,2,3
 * @returns {String}
 */
QueryById.prototype.initPostParams=function(p_ids){
	
	var _params='{"getFeatureMode":"ID", "datasetNames":["'+this._dtSource+':'+this._dtSet+'"], "ids":['+p_ids+']}';
	return _params;
};